
$(".logins").click(function(e){
        var username=$("#username").val();
        var password=$("#password").val();
        $.ajax({
            type:'POST',
            url:'http://localhost:8080/front/login',
            data:{"username":username,"password":password},
            success:function (data) {
                var Objdata=JSON.parse(data);
                $.cookie("name",Objdata.name);
                $.cookie("image",Objdata.image);
                console.log($.cookie("name"));
                $(".login-p").text($.cookie("name"));
                $('#myModal').modal('toggle');
                $(".email").css("display","none");
                window.location.reload()
            },error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert(2+" "+XMLHttpRequest + " " + textStatus + " " + errorThrown)
            }
        });
    }
)
$(".registers").click(
    function (e) {
        var name=$("#name").val();
        var phone=$("#phone").val();
        var password=$("#passwords").val();
        $.ajax({
            url:'http://localhost:8080/front/register',
            type:'POST',
            data:{"name":name,"phone":phone,"password":password},
            success:function (data) {
                $('#myModal1').modal('toggle');
                if(data=="1"){
                    alert("成功")
                }else{
                    alert("失败")
                }

            }
        })
    }
)

new Vue({
    el:"#bs-example-navbar-collapse-1",
    data:{
        name:$.cookie("name"),
        image:$.cookie("image")
    }
})

new Vue({
    el: ".content",
    data(){
        return {
            carddata: [],
            mainlists:[]
        }
    },
    mounted: function () {
        this.mainlist();
    },
    methods:{
        cards: function () {
            axios.post('http://localhost:8080/front/card').then(res => res.data).then(data => {
                this.carddata = data;
            })
        },
        mainlist: function () {
            axios.post('http://localhost:8080/front/rentlist').then(res => res.data).then(data => {
                this.mainlists = data;
            })
        },
        search1: function () {
            var params = new URLSearchParams();
            if ($("#s1 option:selected").text() == "默认") {
                params.append('adress', null);
            } else if ($("#s1 option:selected").text() == "下城区") {
                params.append('adress', "下城区");
            } else if ($("#s1 option:selected").text() == "上城区") {
                params.append('adress', "上城区");
            } else if ($("#s1 option:selected").text() == "滨江区") {
                params.append('adress', "滨江区");
            } else if ($("#s1 option:selected").text() == "拱墅区") {
                params.append('adress', "拱墅区");
            }

            if ($("#s2 option:selected").text() == "默认") {
                params.append('price', null);
            } else if ($("#s2 option:selected").text() == "80万以下") {
                params.append('price', "80");
            } else if ($("#s2 option:selected").text() == "80-150万") {
                params.append('price', "150");
            } else if ($("#s2 option:selected").text() == "150-200万") {
                params.append('price', "200");
            } else if ($("#s2 option:selected").text() == "200-300万") {
                params.append('price', "300");
            }

            if ($("#s3 option:selected").text() == "默认") {
                params.append('area', null);
            } else if ($("#s3 option:selected").text() == "50㎡以下") {
                params.append('area', "50");
            } else if ($("#s3 option:selected").text() == "50㎡-70㎡") {
                params.append('area', "70");
            } else if ($("#s3 option:selected").text() == "70㎡-90㎡") {
                params.append('area', "90");
            } else if ($("#s3 option:selected").text() == "90㎡-130㎡") {
                params.append('area', "130");
            }

            if ($("#s4 option:selected").text() == "默认") {
                params.append('type', null);
            } else if ($("#s4 option:selected").text() == "二室") {
                params.append('type', "二室");
            } else if ($("#s4 option:selected").text() == "三室") {
                params.append('type', "三室");
            } else if ($("#s4 option:selected").text() == "四室") {
                params.append('type', "四室");
            } else if ($("#s4 option:selected").text() == "五室") {
                params.append('type', "五室");
            }

            if ($("#s5 option:selected").text() == "默认") {
                params.append('times', null);
            } else if ($("#s5 option:selected").text() == "50以下") {
                params.append('times', "50");
            } else if ($("#s5 option:selected").text() == "50-100") {
                params.append('times', "100");
            } else if ($("#s5 option:selected").text() == "100-200") {
                params.append('times', "200");
            }

            if ($("#s6 option:selected").text() == "默认") {
                params.append('nice', null);
            } else if ($("#s6 option:selected").text() == "200以下") {
                params.append('nice', "200");
            } else if ($("#s6 option:selected").text() == "200-500") {
                params.append('nice', "500");
            }
            axios.post('http://localhost:8080/front/searchlist2', params).then(res => res.data).then(data => {
                this.mainlists = data;
            })
        }
    }
})